<template>
  <f7-page @page:reinit="getDataItems">
    <f7-navbar title="吉林动画学院公务用车申请表" back-link="Back"></f7-navbar>
    <f7-list inline-labels no-hairlines-md>
      <f7-list-item>
        <f7-label>名称</f7-label>
        <f7-input type="text" :value="formContent.title"  :disabled="true"></f7-input>
      </f7-list-item>
      <f7-list-item>
        <f7-label>申请时间</f7-label>
        <f7-input type="text" :value="formContent.creationDate"  :disabled="true"></f7-input>
      </f7-list-item>

      <f7-list-item  >
        <f7-label>申请部门</f7-label>
        <f7-input type="text"   :value="formContent.orgName" :disabled="true">  </f7-input>
      </f7-list-item>

      <f7-list-item>
        <f7-label>用车事由</f7-label>
        <f7-input type="textarea" :value="formContent.reason" :disabled="true"></f7-input>
      </f7-list-item>

      <f7-list-item>
        <f7-label>乘车人数</f7-label>
        <f7-input type="tel" :value="formContent.usageCount" :disabled="true"></f7-input>
      </f7-list-item>
      <f7-list-item>
        <f7-label>用车开始时间</f7-label>
        <f7-input type="text" :value="formContent.beginDate" :disabled="true"></f7-input>
      </f7-list-item>
      <f7-list-item>
        <f7-label>用车结束时间</f7-label>
        <f7-input type="text"  :value="formContent.endDate" :disabled="true"></f7-input>
      </f7-list-item>
      <f7-list-item>
        <f7-label>用车起始地点</f7-label>
        <f7-input type="text" :value="formContent.address" :disabled="true"></f7-input>
      </f7-list-item>
      <f7-block>
        <f7-label>用车情况</f7-label>
        <f7-row>
          <f7-col width="40"><span>市外用车</span></f7-col>
          <f7-col width="30">
            <f7-toggle color="orange"  :checked="formContent.city" :disabled="true" ></f7-toggle>
          </f7-col>
          <f7-col width="30"><span>市内用车</span></f7-col>
        </f7-row>
      </f7-block>
      <f7-list-item >
        <f7-label>申请人</f7-label>
        <f7-input type="tel"   :value="formContent.createBy"   :disabled="true"></f7-input>
      </f7-list-item>
      <f7-list-item >
        <f7-label>联系电话</f7-label>
        <f7-input type="tel"   :value="formContent.operatorPhone"   :disabled="true"></f7-input>
      </f7-list-item>
      <f7-list-item >
        <f7-label>部门陪同人员</f7-label>
        <f7-input type="text"   :value="formContent.entourage"   :disabled="true"></f7-input>
      </f7-list-item>
      <f7-list-item >
        <f7-label>陪同人员电话</f7-label>
        <f7-input type="tel"   :value="formContent.entouragePhone"   :disabled="true"></f7-input>
      </f7-list-item>

      <f7-list-item >
        <f7-label>部门负责人</f7-label>
        <f7-input type="text"   :value="formContent.depUser"   :disabled="true"></f7-input>
      </f7-list-item>
      <f7-list-item >
        <f7-label>部门主管领导</f7-label>
        <f7-input type="text"   :value="formContent.depManageUser"   :disabled="true"></f7-input>
      </f7-list-item>
      <f7-list-item >
        <f7-label>校务部</f7-label>
        <f7-input type="text"   :value="formContent.schoolUser"   :disabled="true"></f7-input>
      </f7-list-item>
      <f7-list-item >
        <f7-label>校务部主管领导</f7-label>
        <f7-input type="text"   :value="formContent.schoolManageUser"   :disabled="true"></f7-input>
      </f7-list-item>
    </f7-list>
    <f7-list>
      <f7-list-item title="车牌号" v-bind:after="formContent.carNo"></f7-list-item>
      <f7-list-item title="起车公里数" v-bind:after="formContent.startKM"></f7-list-item>
      <f7-list-item title="收车公里数" v-bind:after="formContent.endKM"></f7-list-item>
      <f7-list-item >
        <f7-label>注：合计里程金额（大车：5元/公里，小车：2元/公里）</f7-label>
      </f7-list-item>
    </f7-list>

    <f7-list accordion  >
      <f7-list-item title="流程历史" v-bind:link="'/oa/activities/' + formContent.processInstanceId"></f7-list-item>
      <f7-list-item title="附件数据" v-bind:link="'/oa/attachments/' + formContent.id"></f7-list-item>
      <!--<f7-list-item title="业务审批" link="#" @click="popupOpened = true"></f7-list-item>-->
      <f7-list-item accordion-item  id="m2" :accordion-item-opened="true"  title="业务审批" v-show="paramsId ==-1 ? false : true">
        <f7-accordion-content>
          <f7-block>
            <f7-list inline-labels no-hairlines-md>
              <f7-list-item>
                <f7-input type="textarea" placeholder="请在这里填写批注"  v-bind:value="admitData.comment"   @input="admitData.comment =  $event.target.value"></f7-input>
              </f7-list-item>
              <f7-list-item>
                <img slot="media" v-bind:src="admitData.signature" />
              </f7-list-item>
            </f7-list>
            <f7-button raised href="/oa/personalwork/signature" >手写签名</f7-button>
            <f7-block strong>
              <f7-row>
                <f7-col width="50">
                  <f7-button fill raised @click="superiorDecision('同意')">同意</f7-button>
                </f7-col>
                <f7-col width="50">
                  <f7-button fill raised color="red" @click="superiorDecision('不同意')">不同意</f7-button>
                </f7-col>
              </f7-row>
            </f7-block>
          </f7-block>
        </f7-accordion-content>
      </f7-list-item>

    </f7-list>
  </f7-page>
</template>

<script>
    export default {
      name: "admitCar",
      data() {
        return {
          paramsEntityId: this.$f7route.params.entityId,
          paramsId: this.$f7route.params.id,

          formContent: { },
          admitData: {
            signature: "",
            accepted: "不同意",
            comment: "",
            taskId: 0,
          },
        }
      },
      created() {
        this.$f7ready((f7) => {
          let that = this;
          f7.request.setup({
            headers: {
              'AccessToken': sessionStorage.getItem('accessToken'),
              'JSESSIONID': sessionStorage.getItem('userToken'),
            }
          });
            f7.request.json(that.GLOBAL.RequestAddress + '/camel/rest/carapplys/' +  that.paramsEntityId, { }, function (result) {
              that.formContent = result;
            });
        });
      },
      methods: {
        getDataItems: function () {
          console.log("init")
          let that = this;
          let app = that.$f7;
          let url = that.GLOBAL.RequestAddress + '/camel/rest/carapplys/' + that.paramsEntityId;
          app.request.json(url, {}, function (result) {
            that.formContent = result;
          })
          that.showSignaure();
        },
        superiorDecision: function (opinion) {
          let that = this;
          let app = that.$f7
          let url = that.GLOBAL.RequestAddress + "/camel/rest/carapplys/workflow/completeTask"
          that.admitData.taskId = that.paramsId;
          that.admitData.accepted = opinion;
          //console.log(opinion)
          app.request.json(url, that.admitData, function (result) {
            that.showAlert("提示", result.msg);
          })
        },
        showAlert: function (title, text) {
          let that = this;
          let app = that.$f7
          app.dialog.alert(text, title, () => {
            that.$f7router.back();
          });
        }
      },
      showSignaure : function () {
        let that = this;
        that.admitData.signature = that.$f7.data.admitSig;
        that.$f7.data.admitSig = "";
      },
    }
</script>

<style scoped>

</style>
